package com.dux.shiro1.web.error;

import org.springframework.http.HttpStatus;

/**
 * Title: CodeEnum <br>
 * Description: CodeEnum <br>
 * Date: 2018年10月22日
 *
 * @author 王东旭
 * @version 1.0.0
 * @since jdk8
 */
public enum CodeEnum {
    /**
     * 成功
     */
    SUCCESS(HttpStatus.OK,"0000","success"),

    UNAUTHORIZED(HttpStatus.UNAUTHORIZED,"0001","未认证"),
    /**
     * 登陆异常(01xx)
     */
    LOGIN_CAPTCHA_TIMEOUT("0101","验证码已经失效"),
    LOGIN_CAPTCHA_ERR("0102","验证码错误"),
    LOGIN_USER_PASS_ERR("0103","用户名或密码错误"),
    LOGIN_ERR("0199","验证异常"),

    /**
     * 系统未知异常
     */
    SYSTEM_ERROR(HttpStatus.INTERNAL_SERVER_ERROR,"9999","服务器错误");

    private HttpStatus status;
    private String code;
    private String msg;

    CodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    CodeEnum(HttpStatus status,String code, String msg) {
        this.status = status;
        this.code = code;
        this.msg = msg;
    }

    public HttpStatus getStatus() {
        return status;
    }

    public void setStatus(HttpStatus status) {
        this.status = status;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "CodeEnum{" +
                "status=" + status +
                ", code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                '}';
    }
}
